<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script src="./myPromise.js"></script>
    <script>
      console.log('---程序开始---');
      const p = new myPromise((resolve, reject) => {
        console.log('传给 promise的方法执行');
        // 模拟网络请求
        setTimeout(() => {
          // resolve('我成功了');
          reject('我失败了');
        }, 100);
      });

      p.then()
        .then()
        .then(
          (value) => {
            console.log('then 成功回调==>', value);
          },
          (err) => {
            console.log('then 失败回调==>', err);
          }
        );
      console.log('---程序结束---');
    </script>
  </body>
</html>
